
#include "waterparticle.h"

#include <iostream>
#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
 
float ROT_RATIO = 90.f;

WaterParticle::WaterParticle(void) : Particle(1.f)
{
	setColor();
}

WaterParticle::WaterParticle(float x, float y, float z) : Particle(1.f, x,y,z)
{
	setColor();
}
WaterParticle::WaterParticle(float life,
							 float x, float y, float z,
							 float dx,float dy,float dz) : Particle(life, x,y,z, dx,dy,dz)
{
	setColor();
}

void WaterParticle::setColor()
{
	colors = new float*[1];
	colors[0] = new float[3];
	colors[0][0] = 0.0f + (float)(rand()%10)/100.f;
	colors[0][1] = 0.0f + (float)(rand()%50)/100.f;
	colors[0][2] = 0.5f + (float)(rand()%50)/100.f;
}

void WaterParticle::update(float etime)
{
	Particle::update(etime);
}

void WaterParticle::draw(Vector4 *camPos, Vector4 *camRot)
{
	/*glColor3f(colors[0][0], colors[0][1], colors[0][2]);
	glPushMatrix();
	glTranslatef(pos[0],pos[1],pos[2]);
	glRotatef(-ViewYaw,0.0f,1.0f,0.0f);
    glRotatef(-ViewPitch,1.0f,0.0f,0.0f);
	glutSolidSphere(1.0, 4, 4);
	glPopMatrix();*/
	
	glPushMatrix();
	// Place the quad and rotate to face the viewer
	glColor3f(colors[0][0], colors[0][1], colors[0][2]);
	glTranslatef(pos[0], pos[1], pos[2]);
	glRotatef(camRot->get(0)*ROT_RATIO,0.f,1.f,0.f);
	glRotatef(-1.f*camRot->get(1)*ROT_RATIO,1.f,0.f,0.f);

	glBegin(GL_QUADS);
	 glTexCoord2f(0.f, 0.f);  glVertex3f(-1.f, 1.f, 0.f);
	 glTexCoord2f(0.f, 1.f);  glVertex3f(-1.f,-1.f, 0.f);
	 glTexCoord2f(1.f, 1.f);  glVertex3f( 1.f,-1.f, 0.f);
	 glTexCoord2f(1.f, 0.f);  glVertex3f( 1.f, 1.f, 0.f);
	glEnd();

	glPopMatrix();
}